package db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class dbPool {
	Context ctx;
	private Connection baglanti;
	public dbPool() {
		try {
			ctx = new InitialContext();
			DataSource ds= (DataSource) ctx.lookup("jdbc/emmy");
			baglanti = ds.getConnection();
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// TODO Auto-generated constructor stub
	}
	public ResultSet sorgu(String sql){
		try {
		PreparedStatement state = baglanti.prepareStatement(sql);
		return state.executeQuery();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
	

}
